package com.shrfid.module_base.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * 书籍标签实体类
 */
public class TagEntity implements Parcelable {

    /**
     * 书籍硬件号,可能经过转换
     */
    private String uid;

    /**
     * uid源数据
     */
    private String uidSource;

    /**
     * 书籍条码号
     */
    private String bookNo;

    public TagEntity(String uidSource, String uid, String bookNo) {
        this.uidSource = uidSource;
        this.uid = uid;
        this.bookNo = bookNo;
    }

    public String getUidSource() {
        return uidSource;
    }

    public void setUidSource(String uidSource) {
        this.uidSource = uidSource;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getBookNo() {
        return bookNo;
    }

    public void setBookNo(String bookNo) {
        this.bookNo = bookNo;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TagEntity tagEntity = (TagEntity) o;
        return Objects.equals(uid, tagEntity.uid) &&
                Objects.equals(bookNo, tagEntity.bookNo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(uid, bookNo);
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.uid);
        dest.writeString(this.bookNo);
    }

    protected TagEntity(Parcel in) {
        this.uid = in.readString();
        this.bookNo = in.readString();
    }

    public static final Creator<TagEntity> CREATOR = new Creator<TagEntity>() {
        @Override
        public TagEntity createFromParcel(Parcel source) {
            return new TagEntity(source);
        }

        @Override
        public TagEntity[] newArray(int size) {
            return new TagEntity[size];
        }
    };

    @Override
    public String toString() {
        return "TagEntity{" +
                "uid='" + uid + '\'' +
                ", bookNo='" + bookNo + '\'' +
                '}';
    }
}
